<!DOCTYPE html SYSTEM "http://www.thymeleaf.org/dtd/xhtml1-strict-thymeleaf-4.dtd">
<html lang="en" xmlns="http://www.w3.org/1999/xhtml"
      xmlns:th="http://www.thymeleaf.org">
<head lang="en">
    <meta name="viewport" content="width=device-width,initial-scale=1.0,user-scalable=no"/>
    <meta name="format-detection" content="telephone=no"/>
    <meta name="format-detection" content="email=no"/>
    <meta charset="UTF-8">
    <script type="text/javascript" th:src="@{${session.baseUrl}+'js/common.js'}"></script>
    <script th:src="@{${session.baseUrl}+'js/jquery.js'}"></script>
    <link th:href="@{${session.baseUrl}+'style/reset.css'}" rel="stylesheet" type="text/css">
    <link th:href="@{${session.baseUrl}+'style/base.css'}" rel="stylesheet" type="text/css">
    <link th:href="@{${session.baseUrl}+'style/header.css'}" rel="stylesheet" type="text/css">
    <link rel="stylesheet" th:href="@{${session.baseUrl}+'style/orderMessage.css'}"/>
    <link th:href="@{${session.baseUrl}+'style/dialog.css'}" rel="stylesheet" type="text/css">
    <link th:href="@{${session.baseUrl}+'style/global.css'}" rel="stylesheet" type="text/css">
    <script th:src="@{${session.baseUrl}+'js/dialogbutton.js'}"></script>
    <script th:src="@{${session.baseUrl}+'js/dialog.js'}"></script>
    <title>订单信息</title>
    <style>
        .sub{
            width: 6.3rem;
            background: #2d9cff;
            display: block;
            margin: 0.3rem auto;
            line-height: 0.75rem;
            color: #fff;
            font-size: 0.26rem;
            text-align: center;
            border-radius: 0.1rem;
            cursor: pointer;
            -webkit-appearance: none;
        }
        .sub1{
            width: 6.3rem;
            background: #767476;
            display: block;
            margin: 0.3rem auto;
            line-height: 0.75rem;
            color: #101010;
            font-size: 0.26rem;
            text-align: center;
            border-radius: 0.1rem;
            cursor: pointer;
            -webkit-appearance: none;
        }
        #error{
            padding-left: 0.3rem;
            font-size: 0.3rem;
            line-height: 0.4rem;
            padding-bottom: 0.3rem;
            font-weight: bold;
        }
    </style>
</head>
<body>
<header><span onclick="javascript:history.go(-1)"></span>订单信息</header>
<h1 style="font-size: 0.32rem;color: #323232;font-weight: bold;padding-top: 0.30rem;padding-left: 0.6rem;" th:text="${drafts.name}"></h1>

    <input type="hidden"  id="projectId" name="projectId" th:value="${drafts.id}">
    <input type="hidden"  id="projectName"  name="projectName" th:value="${drafts.name}">
    <input type="hidden"  id="memberId" name="memberId" th:value="${session.memberId}">
    <input type="hidden" th:value="${#numbers.formatDecimal(drafts.totalMoney-drafts.currentTotal,1,2)}" id="projectBalance"/>
    <input type="hidden" id="minMoney" th:value="${drafts.minMoney}">
    <input type="hidden" id="balance" th:value="${balance}">
<input type="hidden" th:value="${drafts.infoI}" name="infoI" id="infoI">

    <div class="pl30 pr30 bgwh">
        <div class="df jcsb aic pl30 pr30 bgwh mt20 all"><span>年化收益率：</span><b style="font-size: 0.4rem;color: red"  th:text="${#numbers.formatDecimal(100*drafts.rate,1,2)}+'%'"></b></div>
        <div class="df jcsb aic pl30 pr30 bgwh mt20 all"><span>剩余可认购金额：</span><b  th:text="${#numbers.formatDecimal(drafts.totalMoney-drafts.currentTotal,1,2)}"></b></div>
        <div class="df jcsb aic pl30 pr30 bgwh mt20 all"><span>最低认购金额：</span><b  th:text="${drafts.minMoney}"></b></div>
        <div class="df jcsb aic pl30 pr30 bgwh mt20 all"><span>可用余额：</span><b style="color: #0ba427" th:text="${balance}"></b></div>
        <div>
            <span id="error"></span>
        </div>

        </div>
    <div class="df jcsb aic pl30 pr30 bgwh mt20 all" style="font-weight: bold"><span>投标金额</span><span id="xianshi"><i th:text="${memberOrder.money}"></i></span></div>
           <div th:if="${drafts.status==1}">
               <span th:if="${memberOrder.payStatus==0}"> <input class="sub" type="submit" onclick="queren()" value="去支付"/></span>
               <span th:if="${memberOrder.payStatus==1}"> <input class="sub1" disabled="disabled"  value="您已支付"/></span>
               <span th:if="${memberOrder.payStatus==2}"> <input class="sub1"  disabled="disabled" value="您已取消"/></span>
               <span th:if="${memberOrder.payStatus==0}"> <input class="sub" type="submit" onclick="quxiaozhifu()" value="取消支付"/></span>
           </div>
           <div th:if="${drafts.status!=1}">
               <span > <input class="sub1"  disabled="disabled" value="项目已结束"/></span>
           </div>




<script type="text/javascript" th:inline="javascript">
    var basePath = /*[[${#httpServletRequest.getScheme() + "://" + #httpServletRequest.getServerName() + ":" + #httpServletRequest.getServerPort() + #httpServletRequest.getContextPath()}]]*/;

    var orderId = [[${memberOrder.id}]]
    var money = [[${memberOrder.money}]]
    function qingchu() {
         $("#error").html("");
    }


    function quxiaozhifu() {
        $.ajax({
            url: "/wap/memberOrder.html/quxiaozhifu",
            contentType: 'application/json',
            type: "get",
            dataType: "json",
            data: {
                orderId:orderId
            },
            success: function (e) {
                if (e.data) {
                    $('body').dailog({type: 'success', title: '取消', discription: ' 取消支付成功'});
                    self.setInterval(function () {
                        window.location.href = basePath + "/wap/mine.html";
                    }, 3000) //这里3000代表3秒
                } else {
                    $('body').dailog({type: 'warning', title: '取消', discription: '取消支付失败'});
                    self.setInterval(function () {
                        location.reload();
                    }, 3000)
                }

            }
        })
    }
    
    
    function queren() {



        var memberBalance = parseInt($("#balance").val());
        var span = $("#error");

         if (money > memberBalance) {
            span.html('余额不足，请充值！').css('color', '#ff2525');
            return false;
        } else {

            $('body').dailogbutton({type: 'success', title: '确认支付', discription: '是否去支付？'},function(ret) {

                if(ret.index===0){
                    window.location.href= basePath+'/wap/memberProject/topay?projectId='+$('#projectId').val()+"&money="+money+"&orderId="+orderId;
                }else{
                    location.reload();
                }


            })

        }








       /* var b = confirm("是否确认购买");
        if (b == true) {
            opentest11();
        } else {
            $.ajax({
                url: "/memberOrder/add2",
                contentType: 'application/json',
                type: "POST",
                dataType: "json",
                data: JSON.stringify({
                    money: $('#money').val(),
                    memberBalance: $('#memberBalance').val(),
                    memberId: $('#memberId').val(),
                    projectId: $('#projectId').val(),
                    payStatus: 0,
                }),
                success: function (e) {
                    if (e.data) {
                        $('body').dailog({type: 'primary', discription: '已取消，可在我的订单中查询'});
                        self.setInterval(function () {  // 这个方法是说在延迟3秒后执行大括号里的方法
                            location.reload();   // 这个方法是刷新当前页面
                        }, 4000) //这里3000代表3秒
                    }
                }
            })
        }
*/






    }











    /*投资金额随着用户输入而更改*/
    $("#inputmoney").bind('input propertychange', function() {
        var number = $("#inputmoney").val();
        $("#xianshi").html('<i>￥</i>'+ number);
    });







</script>
</body>
</html>